package com.qwz.example;

public class Client {

    public static void main(String[] args) throws Exception {
        //准备上下文
        Context context = new Context("");

        //想要获取c元素的name属性，也就是如下表达式的值"root/a/b/c"
        //构建解释器的抽象语法树
        ElementExpression root = new ElementExpression("root");
        ElementExpression a = new ElementExpression("a");
        ElementExpression b = new ElementExpression("b");

        ElementTerminalExpression c = new ElementTerminalExpression("c");
        //组合起来
        root.addEle(a);
        a.addEle(b);
        b.addEle(c);
        //调用
        String[] interpreter = root.interpreter(context);

        System.out.println("c的值是="+interpreter[0]);
    }
}
